package com.hhs.storage.controller;


import com.hhs.storage.bean.Comsumer;
import com.hhs.storage.bean.Driver;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.bean.ResponseInfo;
import com.hhs.storage.service.DriverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * <p>
 * 司机管理
 * </p>
 *
 * @author hhs
 * @since 2022-12-17
 */
@RestController
@RequestMapping("/driver")
public class DriverController {
    @Autowired
    private DriverService driverService;
    @RequestMapping(value = "table")
    public Map<String, Object> getAll(Driver driver,InputParam inputParam) {
        return driverService.getAll(driver,inputParam);
    }
    @PostMapping(value = "edit")
    public Map<String, Object> addOrUpdate(Driver driver,String deleIdStr, MultipartFile[] driverLicenseList, MultipartFile[] healthCertificateList){
        return driverService.addOrUpdate(driver,deleIdStr,driverLicenseList,healthCertificateList);
    }
    @PostMapping(value = "dele")
    public Map dele(String id) {
        try{
            return driverService.dele(id);
        }catch (Exception e){
            e.printStackTrace();
            return ResponseInfo.error("存在关联业务，无法删除");
        }

    }
}

